﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Com.Framework.Data;

namespace Com.Library.DB.Recruit
{
	public class RecruitModel
	{
		private RecruitModel()
		{
		}

		public static int Create(string Name, string PersonalNo, string Phone, string Email,
			string PostNo, string Address, string HopeStore, byte JobTime, string Academic,
			string Career, string License, string FileURL)
		{
			RecruitCreateArguments args = new RecruitCreateArguments()
			{
				strName = Name,
				strPersonalNo = PersonalNo,
				strPhone = Phone,
				strEmail = Email,
				strPostNo = PostNo,
				strAddress = Address,
				strHopeStore = HopeStore,
				n1JobTime = JobTime,
				strAcademic = Academic,
				strCareer = Career,
				strLicense = License,
				strFileURL = FileURL
			};

			RecruitCreate sp = new RecruitCreate();
			sp.SetArguments(args);

			DataEntity result = sp.ExecuteNonQuery();

			return result.GetData2("n4RecruitNo", 0);
		}

		public static RecruitEntity GetInfo(int RecruitNo)
		{
			RecruitGetInfoArguments args = new RecruitGetInfoArguments()
			{
				n4RecruitNo = RecruitNo
			};

			RecruitGetInfo sp = new RecruitGetInfo();
			sp.SetArguments(args);

			RecruitEntity entity = sp.ExecuteNonQuery();

			return entity;
		}

		public static ListData<RecruitEntity, OutputEntity> GetList(byte Status, byte JobTime, int PageNo, byte PageSize)
		{
			RecruitGetListArguments args = new RecruitGetListArguments();
			if (Status != 0)
				args.n1Status = Status;
			if (JobTime != 0)
				args.n1JobTime = JobTime;
			args.PageNo = PageNo;
			args.PageSize = PageSize;
			RecruitGetList sp = new RecruitGetList();
			sp.SetArguments(args);

			List<RecruitEntity> list = sp.Execute();
			OutputEntity output = sp.GetOutput();
			return new ListData<RecruitEntity,OutputEntity>(list, output);
		}

		public static void Modify(int RecruitNo, byte Status, string ManagerName,
			string Description)
		{
			RecruitModifyArguments args = new RecruitModifyArguments()
			{
				n4RecruitNo = RecruitNo,
				n1Status = Status,
				strManagerName = ManagerName,
				strDescription = Description
			};

			RecruitModify sp = new RecruitModify();
			sp.SetArguments(args);

			sp.ExecuteNonQuery();
		}

		public static void Modify(int RecruitNo, string Name, string PersonalNo, string Phone, string Email,
			string PostNo, string Address, string HopeStore, byte JobTime, string Academic,
			string Career, string License, string FileURL, byte Status, string ManagerName,
			string Description)
		{
			RecruitModifyArguments args = new RecruitModifyArguments()
			{
				n4RecruitNo = RecruitNo,
				strName = Name,
				strPersonalNo = PersonalNo,
				strPhone = Phone,
				strEmail = Email,
				strPostNo = PostNo,
				strAddress = Address,
				strHopeStore = HopeStore,
				n1JobTime = JobTime,
				strAcademic = Academic,
				strCareer = Career,
				strLicense = License,
				strFileURL = FileURL,
				n1Status = Status,
				strManagerName = ManagerName,
				strDescription = Description
			};

			RecruitModify sp = new RecruitModify();
			sp.SetArguments(args);

			sp.ExecuteNonQuery();
		}

		public static void Remove(int RecruitNo)
		{
			RecruitRemoveArguments args = new RecruitRemoveArguments()
			{
				n4RecruitNo = RecruitNo
			};

			RecruitRemove sp = new RecruitRemove();
			sp.SetArguments(args);

			sp.ExecuteNonQuery();
		}
	}
}
